package com.biz.primus.ms.oms.service.logs;

import com.biz.primus.model.oms.vo.OmsOrderReturnVo;
import com.biz.primus.model.oms.vo.OmsOrderVo;
import com.biz.primus.model.oms.vo.returns.RefundRequestVo;
import com.biz.primus.ms.base.service.AbstractBaseService;
import com.biz.primus.ms.oms.dao.po.logs.AllocationOrderLogs;
import com.biz.primus.ms.oms.dao.po.logs.CollectionOrderLogs;
import com.biz.primus.ms.oms.dao.repository.logs.AllocationOrderLogsRepository;
import com.biz.primus.ms.oms.dao.repository.logs.CollectionOrderLogsRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yanweijin
 * @date 2017/11/7
 */
@Service
@Slf4j
public class OrderLogsServiceImpl extends AbstractBaseService implements OrderLogsService {

	@Autowired
	private AllocationOrderLogsRepository allocationOrderLogsRepository;

	@Autowired
	private CollectionOrderLogsRepository collectionOrderLogsRepository;

	@Override
	public void logOrderCollection(OmsOrderVo vo, String msg) {
		CollectionOrderLogs collectionOrderLogs=new CollectionOrderLogs();
		collectionOrderLogs.setOrderCode(vo.getCode());
		collectionOrderLogs.setDepotCode(vo.getDepot());
		collectionOrderLogs.setUserId(vo.getUserId());
		collectionOrderLogs.setData(msg);
		collectionOrderLogs.setChannel(vo.getChannel());
		collectionOrderLogs.setId(idService.getNextId());
		collectionOrderLogs.setOrderSource(vo.getOrderSource());
		collectionOrderLogsRepository.save(collectionOrderLogs);
	}

	@Override
	public void logOrderReturnCollection(OmsOrderReturnVo vo, String msg) {

	}

	@Override
	public void logOrderRefundCollection(RefundRequestVo vo, String msg) {

	}

	@Override
	public void logOrderAllocation(String orderCode, String sourceDepotCode, String targetDepotCode, String msg, String operator) {
		AllocationOrderLogs allocationOrderLogs=new AllocationOrderLogs();
		allocationOrderLogs.setMsg(msg);
		allocationOrderLogs.setOperator(operator);
		allocationOrderLogs.setOrderCode(orderCode);
		allocationOrderLogs.setSourceDepotCode(sourceDepotCode);
		allocationOrderLogs.setTargetDepotCode(targetDepotCode);
		allocationOrderLogs.setId(idService.getNextId());
		allocationOrderLogsRepository.save(allocationOrderLogs);
	}


}
